<?php

class Device_model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
        $this->load->database();
    }

    public function getDeviceTrack($deviceSn, $from, $to)
    {
        $this->db->from('device_position');
        $this->db->where('device_sn', $deviceSn);
        $this->db->where('created_at >=',date('Y-m-d H:i:s',$from));
        $this->db->where('created_at <=',date('Y-m-d H:i:s',$to));
        $query = $this->db->get();
//        $str = $this->db->last_query();
//        echo $str;
        return $query->result();
    }
}